package com.cyj.comment.controller;


import com.cyj.comment.service.FollowService;
import com.cyj.comment.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chixiaowai
 * @since 2023-04-04
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Autowired
    private FollowService followService;

    /**
     * 关注和取关
     * @param followUserId  关注的目标ID
     * @param isFollow  是否已关注，已关注就是取关，未关注就是关注
     * @return
     */
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow){
        return followService.follow(followUserId, isFollow);
    }

    /**
     * 判断有没有关注
     * @param followUserId  要判断的目标ID
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId){
        return followService.isFollow(followUserId);
    }

    /**
     * 查询和目标用户的共同关注
     * @param followUserId  目标用户ID
     * @return
     */
    @GetMapping("/common/{id}")
    public Result followCommon(@PathVariable("id") Long followUserId){
        return followService.followCommon(followUserId);
    }
}

